# 内存效率对比
import sys

# 生成器表达式 - 惰性计算
gen_expr = (x**2 for x in range(10))

print(type(gen_expr))  # <class 'generator'>
for it in gen_expr:
    print(it)

# _list = list(gen_expr)
# print("_list====", _list)

# 利用生成器生成0-10之间偶数的平方根
odd_num_sqrt = (num**0.5 for num in range(10) if num % 2 == 0)

for sqrt_num in odd_num_sqrt:
    print("sqrt_num=", sqrt_num)
